package org.wx.thread.thread;

import lombok.SneakyThrows;

/**
 * @description: 线程状态转化
 * @author: wangxun
 * @createDate: 2021/11/26
 * @version: 1.0
 */
public class ThreadState {

    static class Athread implements Runnable{

        @Override
        public void run() {
            try {
                Thread.sleep(1_000);
            } catch (InterruptedException e) {
                System.out.println("a"+e.getMessage());
            }
        }
    }

    @SneakyThrows
    public static void main(String[] args) {
        Thread thread = new Thread(new Athread());
        System.out.println(thread.getState());

        thread.start();

        System.out.println(thread.getState());
        Thread.sleep(100);
        thread.interrupt();
        System.out.println(thread.getState());

        try {
            thread.join();
            System.out.println(thread.getState());
        } catch (InterruptedException e) {
            System.out.println("main"+e.getMessage());
        }


    }

}
